<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  
</head>
<body>
  <script>
    // proxy defineProperty 都是劫持对象
    var obj = {
      a:10,
      b:20
    }

    var proxy = new Proxy(obj,{
      get(target,key){
        
        return target[key];
      },
      set(target,key,v){
        console.log("设置对象属性了");
        target[key]=v;
      }
    })
  
    console.log(proxy.a);
    /* obj.a=50;
    console.log(obj); */
    proxy.a=50;
    console.log(obj);
  </script>
</body>
</html>